﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using permit.App_Code.Entity;
using permit.App_Code.DataAccess;
using permit.App_Code;


namespace permit.Login
{
    public partial class _default : System.Web.UI.Page
    {
        UserAccess userAccess = new UserAccess();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            lblError.Text = "";
            if (TextBoxUserName.Text == "")
            {
                lblError.Text += "用户名或职工编号没有输入，不能登陆！";
                return;
            }
            if (TextBoxPwd.Text == "")
            {
                lblError.Text += "密码没有输入，不能登陆！";
                return;
            }
            string strUserName = TextBoxUserName.Text;
            string strPassWord = TextBoxPwd.Text;
            UserTable userTable = userAccess.GetUser(strUserName, strPassWord);

            if (userTable == null)
            {
                lblError.Text = "用户名，密码错误！";
            }
            else
            {
                Session.Clear();
                Session["UserTable"] = userTable;
                Session.Timeout = 60;
                Response.Redirect("~/main/Default.aspx");
            }
        }
    }
}
